package pl.alef.mindplay.services.impl;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import pl.alef.utils.http.HttpHeaders;

/**
 * 
 * @author apala
 *
 */
public class RemoteAddressHelper {

	public static final String ADDR = "ADDR";
	
	public static Map<String, String> getAddresses(HttpServletRequest request) {
		final Map<String, String> map = new HashMap<String, String>(19);
		
		for (String header : HttpHeaders.CLIENT_ADDR_HEADERS) {
			String value = request.getHeader(header);
			if(value != null) {
				map.put(header, value);
			}
		}
		
		final String addr = request.getRemoteAddr();
		if(addr != null) {
			map.put(ADDR, addr);
		}
		
		return map;
	}
	
	
}
